package com.scau.orderservice.serviceImpl;

import com.alibaba.fastjson.JSONObject;
import com.scau.orderservice.dao.OrderDao;
import model.Order;
import model.Product;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import service.OrderService;
import service.ProductService;

public class OrderServiceImpl implements OrderService {
    @DubboReference
    ProductService productService;
    @Autowired
    OrderDao orderDao;
    @Autowired
    StringRedisTemplate redisTemplate;
    @RabbitListener(queuesToDeclare = @Queue(value = "createOrder"))
    @Override
    public void createOrder(String jsonStr) {
        Order order = JSONObject.parseObject(jsonStr, Order.class);
        redisTemplate.opsForValue().set("order"+order.getOrderId(),jsonStr);
//        将order存放到redis
    }
}
